package com.pda.yuanjing;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;
import com.apkfuns.logutils.LogLevel;
import com.apkfuns.logutils.LogUtils;
import com.pda.yuanjing.beanout.CidInfoBeanOut;
import com.pda.yuanjing.beanout.DealerBeanOut;
import com.pda.yuanjing.beanout.GYSBeanOut;
import com.pda.yuanjing.beanout.PPBeanOut;
import com.pda.yuanjing.beanout.ProductBeanOut;
import com.pda.yuanjing.beanout.StoreBeanOut;
import com.pda.yuanjing.dao.DaoMaster;
import com.pda.yuanjing.dao.DaoSession;
import com.public_module.tools.SharedPreferencesManger;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;

import me.jessyan.autosize.AutoSize;

import static me.jessyan.autosize.utils.LogUtils.isDebug;

public class PDApp extends Application {
    public static final String TAG = "PDApp";
    public static final String showListKey = "showListKey";
    public static final String billID = "billID";
    public static final String batchID = "batchID";
    public static final String process = "process";
    public static final String loacl = "loacl";

    public static ProductBeanOut  productBeanOut = new ProductBeanOut();
    public static StoreBeanOut storeBeanOut = new StoreBeanOut();
    public static DealerBeanOut dealerBeanOut = new DealerBeanOut();
    public static GYSBeanOut gysBeanOut = new GYSBeanOut();

    public static ProductBeanOut  productBeanOutt = new ProductBeanOut();
    public static StoreBeanOut storeBeanOutt = new StoreBeanOut();
    public static DealerBeanOut dealerBeanOutt = new DealerBeanOut();
    public static GYSBeanOut gysBeanOutt = new GYSBeanOut();

    public static CidInfoBeanOut cidInfoBeanOut = new CidInfoBeanOut();
    public static PPBeanOut ppBeanOut = new PPBeanOut();
    public static DaoSession daoSession = null;

    public static boolean scanf = true;
    public static boolean scanfp = true;
    public static boolean scanfs = true;
    public static boolean scanfsc = true;
    public static boolean scanfhm = true;
    public static boolean scanffm = false;

    @Override
    public void onCreate() {
        super.onCreate();
        LogUtils.getLogConfig()
                .configAllowLog(true)  // 是否在Logcat显示日志
                .configTagPrefix("PDApp") // 配置统一的TAG 前缀
                //.configFormatTag("%d{HH:mm:ss:SSS} %t %c{-5}") // 首行显示信息(可配置日期，线程等等)
                .configShowBorders(false) // 是否显示边框
                .configLevel(LogLevel.TYPE_VERBOSE); // 配置可展示日志等级
        SharedPreferencesManger.init(getApplicationContext());
        AutoSize.initCompatMultiProcess(this);
//        AutoSizeConfig.getInstance().getExternalAdaptManager()
//                .addExternalAdaptInfoOfActivity(PictureSelectorActivity.class, new ExternalAdaptInfo(true, 400))
//                .addExternalAdaptInfoOfActivity(PicturePreviewActivity.class, new ExternalAdaptInfo(true, 400))
//                .addExternalAdaptInfoOfActivity(PictureExternalPreviewActivity.class, new ExternalAdaptInfo(true, 400));
        setupDatabase();
        UMConfigure.init(this, "6104ff0426e9627944afb3e1", "default", UMConfigure.DEVICE_TYPE_PHONE, null);
        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
        if (isDebug()) {
            UMConfigure.setLogEnabled(true);
        }
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }

    public void setupDatabase() {
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "pda.db", null);
        SQLiteDatabase db = helper.getWritableDatabase();
        DaoMaster daoMaster = new DaoMaster(db);
        daoSession = daoMaster.newSession();
    }
}
